﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using T68Control.Procdure;
using T68Control.ViewModel;

namespace T68Control.View
{
    /// <summary>
    /// HomeView.xaml 的交互逻辑
    /// </summary>
    public partial class HomeView : UserControl
    {
        public HomeView()
        {
            InitializeComponent();
            var model = new HomeViewModel();
            this.DataContext = model;
            Global.Control = this.VmRenderControl;
            model.SNInputFocusSwitchAction = new System.Action<int>((index) =>
            {
                Application.Current.Dispatcher.Invoke(() =>
                {
                    TextBox focusBox = FindName("tbSN" + index.ToString()) as TextBox;
                    if (focusBox != null)
                    {
                        focusBox.Language = System.Windows.Markup.XmlLanguage.GetLanguage("en-US");
                        focusBox.Focus();
                        focusBox.SelectAll();
                    }
                });
            });
        }

        private void TextBox_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            InputLanguageManager.SetInputLanguage((DependencyObject)sender, CultureInfo.GetCultureInfo("en-US"));
        }

        private void CheckBox_Checked(object sender, RoutedEventArgs e)
        {
            Console.WriteLine("123");
        }
    }
}